package com.weactivity.service.impl;

import com.weactivity.mapper.FileUploadMapper;
import com.weactivity.service.FileUploadService;
import com.weactivity.utils.AliOssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FileUploadServiceImpl implements FileUploadService {

    @Autowired
    private FileUploadMapper fileUploadMapper;


    @Override
    public int insert(int aid, String url) {

     int count =   fileUploadMapper.insert(aid,url);
     return count;

    }

    @Override
    public List<String> showAll(int aid) {
       List<String> urlList =  fileUploadMapper.showAll(aid);
       return urlList;
    }

    @Override
    public int deleteByUrl(int aid, String url) {

     int count =  fileUploadMapper.deleteByUrl(aid,url);
     //使用自定义的阿里云工具删除云服务器上的文件
        AliOssUtil.deleteFile(url);
     return count;
    }
}
